import { App } from 'vue';
import { registerViewProvider } from '@ibiz-template/runtime';
import { withInstall } from '@ibiz-template/vue3-util';
import { ViewPluginProvider } from './view.provider';
import { ViewPlugin } from './view';

export const IBizViewPlugin = withInstall(ViewPlugin, function (v: App) {
  // 全局注册视图插件组件
  v.component(ViewPlugin.name, ViewPlugin);
  // 全局注册视图适配器，VIEW_CUSTOM是插件类型，R9viewPluginId是插件标识
  registerViewProvider(
    'VIEW_CUSTOM_R9viewPluginId',
    () => new ViewPluginProvider(),
  );
});
